<?php

namespace app\adminapi\controller\system;

use app\adminapi\service\SysOperLogService;
use app\adminapi\validate\OperLogValidate;
use app\common\controller\BaseAdminController;

class SysOperLogController extends BaseAdminController
{
    public array $notNeedLogin = [];

    public function list()
    {
        $param = (new OperLogValidate())->get()->goCheck('list');
        $result = (new SysOperLogService())->list($param);
        return app('json')->successWithData($result);
    }

    /**
     * @title 删除操作日志
     * @businessType DELETE
     */
    public function delete()
    {
        $param = (new OperLogValidate())->delete()->goCheck('delete');
        $result = (new SysOperLogService())->deleteOperLog(explode(",", $param['operIds']));
        return app('json')->successWithData($result);
    }

    /**
     * @title 清空操作日志
     * @businessType CLEAR
     */
    public function clear()
    {
        $result = (new SysOperLogService())->clearOperLog();
        return app('json')->successWithData($result);
    }

    public function query()
    {
        $param = (new OperLogValidate())->get()->goCheck('query');
        $result = (new SysOperLogService())->query($param['operId']);
        return app('json')->successWithData($result);
    }
}